/*	kd:
	
	Actual status-bar'ing.
	
	The Doom status bar has the ninja meter, the >>>>>> bar that works like
	in Super Mario 3, but gives you hitscan resistance.
	
	*/

		

class Gc_DoomSbar : Gc_StatusBar {
	
	// Assorted stuff.
	protected Gc_SbarSmoothNinjaMeter	ninja_bar;
	protected Gc_SbarDoomKeys			keys;
	
	// Ammo bars:
	protected Gc_SbarAmmoBars			ammo_bars;
	protected Gc_SbarAmmoGrid			ammo_grid;
	
	override void Init () {
		
		// kd: Calling super.init causes a crash when you don't new ammo_bars,
		// cuz who knows why. We have to do this even though AmmoBars will give
		// us a valid pointer.
		ammo_bars = new("Gc_SbarAmmoBars");
		super.Init();
		
		if(sbar_data_handler) {
			keys = sbar_data_handler.DoomKeysPtr();
			ammo_bars = sbar_data_handler.AmmoBars();
			
			if(!ammo_bars) {
				console.printf("\c[fire]'mr soup the kitchens on fire'");
			}
			
			ammo_grid.InitFromAmmoBars("gshdammo", 7, ammo_bars);
		}
		
		ninja_bar.Load("spdactiv", extra_offset: 2);
	}
	
	override void Tick () {
		super.Tick();
		
		ninja_bar.ToInventory(self, "NinjaToken");
		ninja_bar.NextFade(fade_tics: 10);
		keys.FromInventory(cplayer.mo);
	}
	
	override void Draw (int state, double t) {
		if(NoHud()) {
			return;
		}
		
		super.Draw(state, t);
		keys.DrawBottom(self, 49, -50, scale: 1);
		
		if(10 < screen_blocks) {
			ninja_bar.DrawBottom(self, 104, -34, t);
			ammo_bars.DrawMiniWithAmounts(
				self,
				ammo_font,
				font.cr_gold,
				alpha: automap_alpha,
				text_alpha: automap_alpha);
		}
		
		else {
			ninja_bar.DrawBottom(self, 61, -35, t);
			ammo_grid.DrawFull(self, automap_alpha);
			ammo_bars.DrawFilled(self, 0.15 * automap_alpha);
			ammo_bars.DrawWithAmounts(
				self,
				ammo_font,
				font.cr_gold,
				alpha: automap_alpha,
				text_alpha: automap_alpha);
		}
	}
	
	override void LoadNormalElements () {
		super.LoadNormalElements();
		ammo_grid.InitFromAmmoBars("gshdammo", 7, ammo_bars);
	}
	
	override void LoadBishopElements () {
		super.LoadBishopElements();
		ammo_grid.InitFromAmmoBars("gchdammo", 7, ammo_bars);
	}
}